package cn.net.shuxing.yifu.common.util;

import lombok.Getter;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Getter
public class TimeExample extends CommonExample {

    public TimeExample(Class<?> entityClass) {
        super(entityClass);
    }

    public TimeExample(Class<?> entityClass, boolean exists) {
        super(entityClass, exists);
    }

    public TimeExample(Class<?> entityClass, boolean exists, boolean notNull) {
        super(entityClass, exists, notNull);
    }

    public TimeExample timeGreaterThan(String property, LocalDateTime localDateTime)
    {
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample yearhGreaterThan(String property, int yearCount)
    {
        LocalDateTime localDateTime = LocalDateTime.now();
        localDateTime = localDateTime.plusYears(Long.valueOf(0 - yearCount));
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample monthGreaterThan(String property, int monthCount)
    {
        LocalDateTime localDateTime = LocalDateTime.now();
        localDateTime = localDateTime.plusMonths(Long.valueOf(0 - monthCount));
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample dayGreaterThan(String property, int dayCount)
    {
        LocalDateTime localDateTime = LocalDateTime.now();
        localDateTime = localDateTime.plusDays(Long.valueOf(0 - dayCount));
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample hourGreaterThan(String property, int hourCount)
    {
        LocalDateTime localDateTime = LocalDateTime.now();
        localDateTime = localDateTime.plusHours(Long.valueOf(0 - hourCount));
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample minuteGreaterThan(String property, int minuteCount)
    {
        LocalDateTime localDateTime = LocalDateTime.now();
        localDateTime = localDateTime.plusMinutes(Long.valueOf(0 - minuteCount));
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample secondGreaterThan(String property, int secondCount)
    {
        LocalDateTime localDateTime = LocalDateTime.now();
        localDateTime = localDateTime.plusSeconds(Long.valueOf(0 - secondCount));
        criteria.andGreaterThan(property,localDateTime);
        return this;
    }

    public TimeExample dayEquals(String property, LocalDate localDate)
    {
        criteria.andEqualTo(property,localDate);
        return this;
    }

    public TimeExample equalsToday(String property)
    {
        criteria.andEqualTo(property,LocalDate.now());
        return this;
    }

    public TimeExample between(String property, LocalDate lowDate, LocalDate highDate)
    {
        super.between(property,lowDate,highDate);
        return this;
    }

    public TimeExample between(String property, LocalDateTime lowDateTime, LocalDateTime highDateTime)
    {
        super.between(property,lowDateTime,highDateTime);
        return this;
    }

    public TimeExample equals(String property, LocalDateTime localDateTime)
    {
        super.equals(property,localDateTime);
        return this;
    }

    public TimeExample equals(String property, LocalDate localDate)
    {
        super.equals(property,localDate);
        return this;
    }
}
